package com.demo;


import java.util.Comparator;
import java.util.Optional;
import java.util.stream.Stream;

public class FPDemo {
    public static void main(String[] args) {
        // of返回Stream<String>对象
        Optional<Integer> result = Stream.of("f", "ba", "hello")
                // map返回Stream<Integer>对象
                .map(s -> s.length())
                // filter返回Stream<Integer>对象
                .filter(l -> l <= 3)
                // max终止操作：返回Optional<Integer>
                .max(Comparator.comparingInt(o -> o));
        // 输出2
        System.out.println(result.get());
    }
}
